package com.ruoyi.easyfame.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.easyfame.domain.BankBusinessFunction;
import com.ruoyi.easyfame.service.IBankBusinessFunctionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 银行业务功能Controller
 * 
 * @author ruoyi
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/easyfame/function")
public class BankBusinessFunctionController extends BaseController
{
    @Autowired
    private IBankBusinessFunctionService bankBusinessFunctionService;

    /**
     * 查询银行业务功能列表
     */
    @PreAuthorize("@ss.hasPermi('easyfame:function:list')")
    @GetMapping("/list")
    public TableDataInfo list(BankBusinessFunction bankBusinessFunction)
    {
        startPage();
        List<BankBusinessFunction> list = bankBusinessFunctionService.selectBankBusinessFunctionList(bankBusinessFunction);
        return getDataTable(list);
    }

    /**
     * 导出银行业务功能列表
     */
    @PreAuthorize("@ss.hasPermi('easyfame:function:export')")
    @Log(title = "银行业务功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankBusinessFunction bankBusinessFunction)
    {
        List<BankBusinessFunction> list = bankBusinessFunctionService.selectBankBusinessFunctionList(bankBusinessFunction);
        ExcelUtil<BankBusinessFunction> util = new ExcelUtil<BankBusinessFunction>(BankBusinessFunction.class);
        util.exportExcel(response, list, "银行业务功能数据");
    }

    /**
     * 获取银行业务功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('easyfame:function:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bankBusinessFunctionService.selectBankBusinessFunctionById(id));
    }

    /**
     * 新增银行业务功能
     */
    @PreAuthorize("@ss.hasPermi('easyfame:function:add')")
    @Log(title = "银行业务功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankBusinessFunction bankBusinessFunction)
    {
        return toAjax(bankBusinessFunctionService.insertBankBusinessFunction(bankBusinessFunction));
    }

    /**
     * 修改银行业务功能
     */
    @PreAuthorize("@ss.hasPermi('easyfame:function:edit')")
    @Log(title = "银行业务功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankBusinessFunction bankBusinessFunction)
    {
        return toAjax(bankBusinessFunctionService.updateBankBusinessFunction(bankBusinessFunction));
    }

    /**
     * 删除银行业务功能
     */
    @PreAuthorize("@ss.hasPermi('easyfame:function:remove')")
    @Log(title = "银行业务功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bankBusinessFunctionService.deleteBankBusinessFunctionByIds(ids));
    }
}
